package com.beep.erp.model.stockdetail;

import com.beep.erp.common.base.BaseBean;
import com.beep.erp.common.bean.BizStorageLocationsListBean;
import com.beep.erp.common.bean.StockListBean;
import com.beep.erp.http.HttpRetrofit;
import com.beep.erp.http.RetryWhenNetworkException;
import com.beep.erp.model.addinstock.SaveStockBody;

import rx.Observable;

/**
 * Created by Jolly on 2018/8/2.
 */

public class StockDetailModel implements StockDetailContract.Model {
    @Override
    public Observable<StockListBean> getStockDetail(String sign, String timeStamp, String purchaseId) {
        return HttpRetrofit.getInstance().apiService.getStockDetail(sign, timeStamp, purchaseId).compose(HttpRetrofit.toSubscribe()).compose(HttpRetrofit.toTransformer()).retryWhen(new RetryWhenNetworkException());
    }

    @Override
    public Observable<BaseBean> saveInstock(String sign, String timeStamp, SaveStockBody saveStockBody) {
        return HttpRetrofit.getInstance().apiService.saveInstock(sign, timeStamp, saveStockBody).compose(HttpRetrofit.toSubscribe()).compose(HttpRetrofit.toTransformer()).retryWhen(new RetryWhenNetworkException());
    }

    @Override
    public Observable<BizStorageLocationsListBean> getBizStorageLocationList(String sign, String timeStamp, String type) {
        return HttpRetrofit.getInstance().apiService.getBizStorageLocationList(sign, timeStamp, type).compose(HttpRetrofit.toSubscribe()).compose(HttpRetrofit.toTransformer()).retryWhen(new RetryWhenNetworkException());
    }
}
